from pydantic import BaseModel, Field
from typing import Optional


class GenColumnBase(BaseModel):
    name: str = Field(..., max_length=64, description="列名称")
    comment: Optional[str] = Field(None, max_length=256, description="列描述")
    type: str = Field("String", max_length=32, description="SQLA 模型列类型")
    pd_type: str = Field("str", max_length=32, description="列类型对应的 pydantic 类型")
    default: Optional[str] = Field(None, description="列默认值")
    sort: Optional[int] = Field(None, description="列排序")
    length: int = Field(0, description="列长度")
    is_pk: bool = Field(False, description="是否主键")
    is_nullable: bool = Field(False, description="是否可为空")
    gen_business_id: int = Field(..., description="所属业务ID")


class GenColumnCreate(GenColumnBase):
    pass


class GenColumnUpdate(GenColumnBase):
    pass